﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CommandLineParserTest.cs" company="Matthias Friedrich">
//   Copyright © Matthias Friedrich 2013
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace CommandLineHandling.UnitTest
{
    using System.Collections.Generic;
    using System.Linq;

    using CommandlineHandling;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class CommandLineParserTest
    {
        public TestContext TestContext { get; set; }

        [TestMethod]
        public void ParseTest()
        {
            IEnumerable<string> args = new[] { "/x", "-y:1", "-z:2", "/say:\"Hello World.\"", "/list", "-item:1", "-item:2", "-item:3" };

            var handler = new CommandLineHandler();

            var target = new CommandLineParser(handler);

            IEnumerable<ICommandLineOption> actual = target.Parse(args);

            IEnumerable<int> listOption = actual.FindByName("list").FindParametersName("item").Select(x => (int)x).ToList();

            Assert.IsTrue(listOption.Contains(1));
            Assert.IsTrue(listOption.Contains(2));
            Assert.IsTrue(listOption.Contains(3));
        }
    }
}